<?php
/**
 * Created by PhpStorm.
 * User: 王文凡<787802868@qq.com>
 * Date: 2016/9/2 0002
 * Time: 09:15
 */

namespace Mobile\Controller;
use Think\Controller;

class WorkOrderController extends Controller
{

    //手机工单列表
    public function workList()
    {

        $list=D('Workorder')->lister();
        $this->assign('_list',$list);
        $this->display();
    }
    //新建工单
    public function workadd()
    {
        if(IS_POST){
            $wap_userId=$_COOKIE['wap_userId'];
            $_POST['formid']=$wap_userId;
            $arr= D('Workorder')->orderadd($_POST);
           if($arr['state']=='success'){
               $data['url']=U('Admin/Works/listers');
               $data['sr_time']=time();
               $data['content']="【新工单提醒】请尽快查看处理!";
               D('Inform')->add($data);
               $this->success($arr['info'],U('WorkOrder/workList'));
           } else{
               $this->error($arr['info']);
           }
        }else{

            $this->display();
        }

    }
    //修改工单
    public function wordUpdate($wid='')
    {
        if(IS_POST){
            $arr= D('Workorder')->orderadd($_POST);
            if($arr['state']=='success'){
                $data['url']=U('Admin/Works/listers');
                $data['sr_time']=time();
                $data['content']="【工单更新提醒】请尽快查看处理!";
                D('Inform')->add($data);
                $this->success($arr['info'],U('WorkOrder/workList'));
            } else{
                $this->error($arr['info']);
            }
        }else{
            $vo=M('Workorder')->where("wid=%d",$wid)->find();
            $this->assign('vo',$vo);
            $this->display();
        }

    }
    //完成工单
    public function comwork($wid='')
    {

        if(M('Workorder')->where("wid=%d",$wid)->save(['status'=>2])){
            $this->success('提交成功','',IS_AJAX);
        }else{
            $this->error('提交失败','',IS_AJAX);
        }

    }
}




















